Fire up your applications with Jetfire
RSS
Jetfire Wiki


Quick Search
»
Advanced Search »

Page History: Jetfire Code: Contact Lists

Compare Page Revisions



« Older Revision - Back to Page History - Current Revision


Page Revision: 2009/07/29 03:18


Table of Contents [Hide/Show]


Jetfire Code: Contact Lists

The Jetfire Code Class for Contact Lists is shown below in the box. This file contains a set of classes that are used in Contact Workflows.

// C O N T A C T   L I S T S     W O R K F L O W
//===================================================================================
// ContactLists.txt
//===================================================================================
// Copyright (C) 2007 TrackerRealm Corporation
// This file is part of Jetfire.  http://Jetfire.ca
// 
// Jetfire is open software: you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software Foundation,
// version 3 of the License.
// 
// Jetfire is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 
// without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
// See the GNU General Public License for more details.
// 
// You should have received a copy of the GNU General Public License along with Jetfire.  
// If not, see http://www.gnu.org/licenses.
// REMOVAL OF THIS NOTICE IS VIOLATION OF THE COPYRIGHT.
//===================================================================================
//
// This file contains classes for:
// - Tag: a generic 'tag' used for categorization of workflows
// - Note: a simple note to add text
// - Address: a general address for a contact
// - EmailAddres: an email address for a contact
// - Phone: a phone number for a contact

namespace JetfireContacts
{
	// DisplayName = "Tag";
	// ToolTip = "Represents a general tag used for categorization.";
	public workflow Tag
	{
		// C O N S T R U C T O R - Instantiate the Tag
		public Tag()
		{
			Subject = " New Tag";
		}
		public Tag(string subject)
		{
			Subject = subject;
			ToolTip = subject;
		}
		public Tag(string subject, string tooltip)
		{
			Subject = subject;
			ToolTip = tooltip;
		}
	}

	// DisplayName = "Note";
	// ToolTip = "Notes may be managed as a workflow.  This makes it simple to add states for the note, who can/cannot edit the note, add more properties and more."
	public workflow Note
	{
		// C O N S T R U C T O R
		public Note()
		{
			Subject = " New Note";
			FileType = FileType.None;
			Tags = new List();
			enterstate Start();
		}
		public Note(string subject)
		{
			Subject = subject;
			FileType = FileType.None;
			Tags = new List();
			enterstate Start();
		}
		public Note(string subject, string body)
		{
			Subject = subject;
			Body = body;
			FileType = FileType.None;
			Tags = new List();
			enterstate Start();
		}
		// S T A T E S
		// State Transition        Command       Comment
		// Instantiate -> Start    New           The configuration object enters the New state when instantiated
		// Start -> Valid          Approve       The user approves the data
		// Valid -> Deleted        Delete        This is an end state
		//
		// S T A T E   M E T H O D S
		public Start()
		{
		}
		public Valid()
		{
		}
		public Deleted()
		{
		}
		public Superceded()
		{
		}
		// C O M M A N D S
		// The Approve command is used to promote the note
		public void Approve() : states(Start, Deleted)
		{
			enterstate Valid();
		}
		// The Delete command is used to delete the note
		public void Delete() : states(Valid)
		{
			enterstate Deleted();
		}
		// The Supercede command is used to supercede the note
		public void Supercede() : states(Valid)
		{
			enterstate Superceded();
		}
		// P R O P E R T I E S
		public string Body
		{
			get;
			set;
		}
		public FileType FileType
		{
			get;
			set;
		}
		public List Tags
		{
			get;
			private set;
		}
	}

	// DisplayName = "Address";
	// ToolTip = "This is an address that can be used with contacts.";
	public workflow Address
	{
		// C O N S T R U C T O R - Instantiate the Address
		public Address()
		{
			Subject = " Address";
			Country = Country.None;
			AddressType = LocationType.None;
		}
		public Address(string subject)
		{
			Subject = subject;
			ToolTip = subject;
			Country = Country.None;
			AddressType = LocationType.None;
		}
		public Address(string subject, string tooltip)
		{
			Subject = subject;
			ToolTip = tooltip;
			Country = Country.None;
			AddressType = LocationType.None;
		}

		// PROPERTIES
		string address1;
		string address2;
		string city;
		string pc;
		Province province = Province.None;

		public string Address1
		{
			get { return address1;		}
			set
			{ 
				address1 = value; 
				UpdateSubject();
			}
		}
		public string Address2
		{
			get { return address2;		}
			set
			{ 
				address2 = value; 
				UpdateSubject();
			}
		}
		public string City
		{
			get { return city;			}
			set
			{ 
				city = value; 
				UpdateSubject();
			}
		}
		public string PostalCode
		{
			get { return pc;			}
			set
			{ 
				pc = value; 
				UpdateSubject();
			}
		}
		public Province Province
		{
			get { return province;		}
			set
			{ 
				province = value; 
				UpdateSubject();
			}
		}
		public Country Country
		{
			get;
			set;
		}
		public LocationType AddressType
		{
			get;
			set;
		}
		private void UpdateSubject()
		{
			string s;
			if (address1.Length > 0)
			{
				s = address1;
			}
			if (address2.Length > 0)
			{
				s += " " + address2;
			}
			if (city.Length > 0)
			{
				s += " " + city;
			}
			s += " " + province.ToString();
			if (pc.Length > 0)
			{
				s += " " + pc;
			}
			Subject = s;
		}
	}

	// DisplayName = "EmailAddress";
	// ToolTip = "This is an email address that can be used with contacts.";
	public workflow EmailAddress
	{
		// C O N S T R U C T O R - Instantiate the EmailAddress
		public EmailAddress()
		{
			Subject = " Email Address";
			EmailAddressType = LocationType.None;
		}
		public EmailAddress(string subject)
		{
			Subject = subject;
			ToolTip = subject;
			EmailAddressType = LocationType.None;
		}
		public EmailAddress(string subject, string tooltip)
		{
			Subject = subject;
			ToolTip = tooltip;
			EmailAddressType = LocationType.None;
		}

		// PROPERTIES
		string emailName;
		string address;

		public string Address
		{
			get { return address;		}
			set 
			{ 
				address = value;	
				UpdateSubject();
			}
		}
		public string EmailName
		{
			get { return emailName;	}
			set 
			{ 
				emailName = value;	
				UpdateSubject();
			}
		}
		public LocationType EmailAddressType
		{
			get;
			set;
		}

		// Private Methods
		private void UpdateSubject()
		{
			string s;
			if (address.Length > 0)
			{
				s = "Email: " + address;
			}
			if (emailName.Length > 0)
			{
				s += " (";
				s += emailName;
				s += ")";
			}
			Subject = s;
		}
	}

	// DisplayName = "Phone";
	// ToolTip = "This is an phone number that can be used with contacts.";
	public workflow Phone
	{
		// C O N S T R U C T O R - Instantiate the Phone Number
		public Phone()
		{
			Subject = " Phone Number";
			PhoneNumberType = LocationType.None;
		}
		public Phone(string subject)
		{
			Subject = subject;
			ToolTip = subject;
			PhoneNumberType = LocationType.None;
		}
		public Phone(string subject, string tooltip)
		{
			Subject = subject;
			ToolTip = tooltip;
			PhoneNumberType = LocationType.None;
		}

		// PROPERTIES
		string number;
		string extension;

		public string PhoneNumber
		{
			get { return number;		}
			set 
			{ 
				number = value;
				UpdateSubject();
			}
		}
		public string Extension
		{
			get { return extension;	}
			set 
			{
				extension = value;
				UpdateSubject();
			}
		}     
		public LocationType PhoneNumberType
		{
			get;
			set;
		}

		// Private Methods
		private void UpdateSubject()
		{
			string s;
			if (number.Length > 0)
			{
				s = "Phone: " + number;
			}
			if (extension.Length > 0)
			{
				s += " x:";
				s += extension;
			}
			Subject = s;
		}
	}
}

ScrewTurn Wiki version 3.0.4.560. Some of the icons created by FamFamFam.